home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Forcing a draw
- Sent: 5/18/96 7:31 AM
- Received: 5/22/96 8:31 AM
- From: Arni McKinley, motion@nbn.com
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- >Bill Finzer
- >Key Curriculum Press
-
- >In a DoMouseDown of a subView, the user is dragging a point in a graph, thus
- >changing the data in the model layer. The model has dependents, including
- >some views, which are notified of the change. The views need to redraw
- >themselves immediately; i.e., without waiting for an update, so that the user
- >gets feedback about the effects of the drag during the drag.
- >
- >I have been unable to discover any way to force an immediate redraw of an
- >individual view. Can anyone help me?
-
-
- Bill,
-
- The solution to your particular problem has to do with the following insight:
- A given part content may appear in several frames. It should happen that
- when you change that content it should change everywhere. On the other
- hand, each frame is a unique presentation of the content; you should be
- able to change the drawing of that presentation of the content
- independently of what is being shown in other frames. One frame may show a
- larger scaled drawing of the content than another for example, or it may
- show the content scrolled, or may show a different presentation entirely
- (say a 3D presentation).
-
- Finally any given frame may be showing its particular presentation through
- various facets and every facet whould be showing exactly the same drawing
- of that presentation as every other facet.
-
- A simple example of multiple frames is this: Suppose your part is embedded
- in a container. It is being seen by the user through one frame; now the
- user opens the part and sees it through a window ("View In Window"). There
- are now two frames open showing the same content.
-
- How to achieve this in ODF?
- (1) Make sure that the content is carried by your part code. DR1 now has a
- "FW_CContent" which takes care of carrying content. You can use that for
- the part; ODFDraw has several very good example of its use.
- (2) Make sure that all variables which describe the view of the content are
- carried by the frame and its subviews. The frame is now a FW_CSuperView. A
- scaling factor for example is a good variable to keep in the frame or its
- main subview.
- (3) Make sure that you use the Draw() method of the frame to draw larger
- frame related things, like outlines around the frame etc, and the subviews
- to draw their own things (the main view would draw the content). Just what
- draws what is somewhat arbitrary, but there are some considerations
- depending upon the content.
- (4) Generally all drawing is done automatically on the update. Generate
- updates by calling "view->Invalidate(ev)". Including a rectangle or ODShape
- will isolate the update region effectively; leaving them out invalidates
- the entire view shape. There is a third parameter in DR1 (I forget if it
- was in d11, but I don't think so) which allows you to specify whether to
- invalidate the same view in all frames. This is useful if you change the
- content of the part and want the frames to change their views accordingly.
- (5) Since frames all have a different FW_CPresentation, invalidations are
- actually shipped through the frame's presentation. You can do the same if
- you want to invalidate directly, though this isn't usually necessary.
- Invalidate does it better. For example:
- frame->GetPresentation()->Invalidate()
- (6) Suppose you have an object you want to redraw wihtin a single facet at
- an odd time, like a shape during a mouseDown. You can get hold of the facet
- within which a mouseDown has occurred by asking the mouseEvent:
- ODFacet* theFacet = theMouseEvent.GetFacet(ev);
- FW_CViewContext vc(ev, this, theFacet );
- theShape->RenderShape(ev, theFacet, vc);
- (7) Suppose you want to set the time in a display area while a simulation
- is one frame is underway and you don't want to wait for the update. You
- might do this:
-
- void ContrlrFrame::SetCurrentTime( Environment *ev, FW_Double time )
- {
- fContrlrView->SetCurrentTime( ev, time );
-
- // Now draw thie current time to all of the frame's facets
- // Acquire it since we get rid of it locally
- FW_CAcquiredODShape invalidShape = fContrlrView->GetPresTextShape(ev);
- DrawAllFacets( ev, invalidShape );
- }
- void ContrlrFrame::DrawAllFacets( Environment *ev, ODShape *invalidShape )
- {
- FW_CFrameFacetIterator facetIte(ev, this);
- for (ODFacet* facet = facetIte.First(ev);
- facetIte.IsNotComplete(ev); facet = facetIte.Next(ev))
- {
- Draw( ev, facet, invalidShape );
-
- FW_CAcquiredODShape aqClipShape =
- facet->AcquireAggregateClipShape(ev, NULL);
- fContrlrView->Draw(ev, facet, aqClipShape );
- }
- }
-
- Notice that setting the time in this context is something that happens in a
- given frame. All of the other frames could be running their simulations
- simultaneously. The part content is the shapes; the content is being viewed
- through different frames, so, if you don't want to save the paths of the
- shapes with the shape, but with the frame, you could have the shapes doing
- very different things in all the different frames.
-
- Hope this is of help to you.
-
- Arni
-
-